home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / Network / MacHTTP 1.2.4 / search.script < prev   
Text File  |  1994-02-23  |  1KB  |  21 lines

  1. -- This script demonstrates accessing searchable files from MacHTTP.
  2. -- (What it really shows is how to pass arguments to AppleScripts.)
  3. -- http_search_args is a predefined variable that is passed from the server
  4. --  to the script and contains the user-supplied arguments. If the arguments
  5. --  are empty, the script asks the WWW client to prompt for them. 
  6. --  If arguments were passed, then the script behaves accordingly.
  7. --  Note: the <ISINDEX> HTML tag is what tells the client the document is searchable
  8. --    and arguments should be collected and passed. 
  9.  
  10. set crlf to (ASCII character 13) & (ASCII character 10)
  11. set http_10_header to "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf & ¬
  12.     "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf
  13.     
  14. if http_search_args = "" then
  15.     return http_10_header & "<ISINDEX><h2>Please enter the keyword to search for.</h2>"
  16. else if http_search_args = "hello" then
  17.     return http_10_header & "<h2>Hello, how are you?</h2>"
  18. else
  19.     return http_10_header & "<h2>Sorry, I don't understand '" & ¬
  20.         http_search_args & "'. Try 'hello' instead.</h2>"
  21. end if